package es.greenandroid.contact;

import es.greenandroid.main.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class ContactView extends View {
	// Contact background parameters
	private int background_color;
	private Paint background_paint;
	// Number messages parameters
    private float circle_position_x;
    private float circle_position_y;
	private int circle_radius;
	private int circle_color;
    private Paint circle_paint;
    private String number_messages;
	// Full name parameters
	private String fullname;
	private Paint fullname_paint;
	
	/**
     * Constructor. This version is only needed if you will be instantiating
     * the object from a layout XML file, initializing with any attributes we 
     * understand. These attributes are defined in:
     * res/values/attrs.xml
     * 
     * @param context
     * @param attributes
     */
	public ContactView(Context context, AttributeSet attributes) {
		super(context, attributes);
		
		TypedArray attributesList = context.obtainStyledAttributes(attributes, R.styleable.es_greenandroid_contact_ContactView);

		// Contact background values
		String backgroundColor = attributesList.getString(R.styleable.es_greenandroid_contact_ContactView_backgroundColor);
		this.background_color = Color.parseColor(backgroundColor);
		this.background_paint = new Paint();
		this.background_paint.setColor(this.background_color);
		
		// Number messages values
		String circleColor = attributesList.getString(R.styleable.es_greenandroid_contact_ContactView_circleColor);
		this.circle_color = Color.parseColor(circleColor);
		this.circle_paint = new Paint();
		this.circle_paint.setAntiAlias(true);
		this.circle_paint.setColor(this.circle_color);
		this.circle_radius = 10;
		this.number_messages = attributesList.getString(R.styleable.es_greenandroid_contact_ContactView_numberMessages);
		
		// Fullname value
		this.fullname = attributesList.getString(R.styleable.es_greenandroid_contact_ContactView_fullName);
	}
}
